home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 June / PersonalComputerWorld-June2009-CoverdiscCD.iso / Software / Shareware / Mockups for Desktop 1.5.27 / MockupsForDesktop.air / MockupsAir.swf / scripts / UnsavedChangesDialog.as < prev   
Encoding:
Text File  |  2009-03-03  |  6.9 KB  |  212 lines

  1. package
  2. {
  3.    import com.plus9.mockups.InputManager;
  4.    import com.plus9.mockups.dialogs.BaseDialog;
  5.    import com.plus9.mockups.ui.OKCancel;
  6.    import flash.accessibility.*;
  7.    import flash.data.*;
  8.    import flash.debugger.*;
  9.    import flash.desktop.*;
  10.    import flash.display.*;
  11.    import flash.errors.*;
  12.    import flash.events.*;
  13.    import flash.external.*;
  14.    import flash.filesystem.*;
  15.    import flash.filters.*;
  16.    import flash.geom.*;
  17.    import flash.html.*;
  18.    import flash.html.script.*;
  19.    import flash.media.*;
  20.    import flash.net.*;
  21.    import flash.printing.*;
  22.    import flash.profiler.*;
  23.    import flash.system.*;
  24.    import flash.text.*;
  25.    import flash.ui.*;
  26.    import flash.utils.*;
  27.    import flash.xml.*;
  28.    import mx.binding.*;
  29.    import mx.containers.ControlBar;
  30.    import mx.containers.VBox;
  31.    import mx.controls.Button;
  32.    import mx.controls.Text;
  33.    import mx.core.UIComponentDescriptor;
  34.    import mx.core.mx_internal;
  35.    import mx.events.PropertyChangeEvent;
  36.    import mx.styles.*;
  37.    
  38.    public class UnsavedChangesDialog extends BaseDialog
  39.    {
  40.       public var path:String;
  41.       
  42.       private var _981817656_message:Text;
  43.       
  44.       private var _documentDescriptor_:UIComponentDescriptor;
  45.       
  46.       private var _1541307179_okCancel:OKCancel;
  47.       
  48.       public function UnsavedChangesDialog()
  49.       {
  50.          _documentDescriptor_ = new UIComponentDescriptor({
  51.             "type":BaseDialog,
  52.             "propertiesFactory":function():Object
  53.             {
  54.                return {
  55.                   "width":300,
  56.                   "height":180,
  57.                   "childDescriptors":[new UIComponentDescriptor({
  58.                      "type":VBox,
  59.                      "stylesFactory":function():void
  60.                      {
  61.                         this.left = "10";
  62.                         this.top = "10";
  63.                         this.bottom = "10";
  64.                         this.right = "10";
  65.                      },
  66.                      "propertiesFactory":function():Object
  67.                      {
  68.                         return {"childDescriptors":[new UIComponentDescriptor({
  69.                            "type":Text,
  70.                            "id":"_message",
  71.                            "propertiesFactory":function():Object
  72.                            {
  73.                               return {
  74.                                  "styleName":"boldFont",
  75.                                  "percentWidth":100,
  76.                                  "height":40
  77.                               };
  78.                            }
  79.                         }),new UIComponentDescriptor({
  80.                            "type":Text,
  81.                            "propertiesFactory":function():Object
  82.                            {
  83.                               return {"text":"Your changes will be lost if you don\'t save them."};
  84.                            }
  85.                         })]};
  86.                      }
  87.                   }),new UIComponentDescriptor({
  88.                      "type":ControlBar,
  89.                      "propertiesFactory":function():Object
  90.                      {
  91.                         return {"childDescriptors":[new UIComponentDescriptor({
  92.                            "type":Button,
  93.                            "events":{"click":"___UnsavedChangesDialog_Button1_click"},
  94.                            "propertiesFactory":function():Object
  95.                            {
  96.                               return {"label":"Don\'t Save"};
  97.                            }
  98.                         }),new UIComponentDescriptor({
  99.                            "type":OKCancel,
  100.                            "id":"_okCancel",
  101.                            "events":{
  102.                               "close":"___okCancel_close",
  103.                               "cancel":"___okCancel_cancel"
  104.                            },
  105.                            "stylesFactory":function():void
  106.                            {
  107.                               this.horizontalAlign = "right";
  108.                            },
  109.                            "propertiesFactory":function():Object
  110.                            {
  111.                               return {"percentWidth":100};
  112.                            }
  113.                         })]};
  114.                      }
  115.                   })]
  116.                };
  117.             }
  118.          });
  119.          super();
  120.          mx_internal::_document = this;
  121.          this.title = "Unsaved Changes";
  122.          this.width = 300;
  123.          this.height = 180;
  124.       }
  125.       
  126.       [Bindable(event="propertyChange")]
  127.       public function get _okCancel() : OKCancel
  128.       {
  129.          return this._1541307179_okCancel;
  130.       }
  131.       
  132.       protected function onSave(param1:MouseEvent = null) : void
  133.       {
  134.          dispatchEvent(new Event("save"));
  135.          super.onCancel();
  136.       }
  137.       
  138.       public function ___okCancel_cancel(param1:Event) : void
  139.       {
  140.          onCancel();
  141.       }
  142.       
  143.       protected function onDontSave(param1:MouseEvent) : void
  144.       {
  145.          dispatchEvent(new Event("dontsave"));
  146.          super.onCancel();
  147.       }
  148.       
  149.       public function setFileNamePath(param1:String, param2:String) : void
  150.       {
  151.          path = param2;
  152.          if(param1 == "")
  153.          {
  154.             param1 = "New Mockup";
  155.          }
  156.          _message.text = "Do you want to save the changes you made in the document \"" + param1 + "\"?";
  157.          _okCancel.okLabel = param1 == "New Mockup" ? "Save..." : "Save";
  158.          _okCancel.okBtn.setFocus();
  159.       }
  160.       
  161.       [Bindable(event="propertyChange")]
  162.       public function get _message() : Text
  163.       {
  164.          return this._981817656_message;
  165.       }
  166.       
  167.       override public function initialize() : void
  168.       {
  169.          mx_internal::setDocumentDescriptor(_documentDescriptor_);
  170.          super.initialize();
  171.       }
  172.       
  173.       public function set _okCancel(param1:OKCancel) : void
  174.       {
  175.          var _loc2_:Object = this._1541307179_okCancel;
  176.          if(_loc2_ !== param1)
  177.          {
  178.             this._1541307179_okCancel = param1;
  179.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_okCancel",_loc2_,param1));
  180.          }
  181.       }
  182.       
  183.       public function set _message(param1:Text) : void
  184.       {
  185.          var _loc2_:Object = this._981817656_message;
  186.          if(_loc2_ !== param1)
  187.          {
  188.             this._981817656_message = param1;
  189.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_message",_loc2_,param1));
  190.          }
  191.       }
  192.       
  193.       public function ___okCancel_close(param1:Event) : void
  194.       {
  195.          onSave();
  196.       }
  197.       
  198.       override public function init(param1:InputManager) : void
  199.       {
  200.          super.init(param1);
  201.          defaultButton = _okCancel.okBtn;
  202.          _okCancel.okBtn.setFocus();
  203.       }
  204.       
  205.       public function ___UnsavedChangesDialog_Button1_click(param1:MouseEvent) : void
  206.       {
  207.          onDontSave(param1);
  208.       }
  209.    }
  210. }
  211.  
  212.